package com.yrk.dao.impl;

import com.yrk.dao.KeyWordsDao;
import com.yrk.unity.GetConn;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class KeyWordsDaoImpl implements KeyWordsDao {
    Connection conn = GetConn.getConnection();
    PreparedStatement ps = null;
    ResultSet rs = null;
    List<String> list=new ArrayList<String>();
    @Override
    public List<String> search(String keyName) {
        try {
            ps=conn.prepareStatement("select keywords_name from keywords where keywords_name like ?");
            ps.setString(1, "%"+keyName+"%");
            rs=ps.executeQuery();
            while(rs.next()) {
                list.add(rs.getString("keywords_name"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
